﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using WpfSnqkGasAnalysis.IData;
using WpfSnqkGasAnalysis.IData_impl;

namespace WpfSnqkGasAnalysis.Common
{
    /// <summary>
    /// 初始化接口、实例。依赖注入配置
    /// </summary>
    /// 创建时间：2022-11-24 10:05:54。作者：王浩力
    public class ServicesHelpter
    {
        public static readonly IServiceProvider serviceProvider = null;

        /// <summary>
        /// 依赖注入
        /// </summary>
        static ServicesHelpter()
        {

            Microsoft.Extensions.DependencyInjection.IServiceCollection services =
                new Microsoft.Extensions.DependencyInjection.ServiceCollection();

            services.AddSingleton<ILogin_userDAL, Login_userDAL_impl>();
            services.AddSingleton<ILogin_logDAL, LoginlogDAL_impl>();
            services.AddSingleton<IOperate_logDAL, Operate_logDAL_impl>();
            services.AddSingleton<IGas_analysisDAL, Gas_analysisDAL_impl>();
            services.AddSingleton<ISource_dictDAL, Source_dictDAL_impl>();
            services.AddSingleton<IGas_check_historyDAL, Gas_check_historyDAL_impl>();
            services.AddSingleton<IGas_analysis_upload_logDAL,  Gas_analysis_upload_logDAL_impl>();

            services.AddSingleton<ICleanGasDAL, CleanGasDAL_impl>();
            services.AddSingleton<IClean_gas_check_historyDAL, Clean_gas_check_historyDAL_impl>();
            services.AddSingleton<IClean_gas_update_logDAL, Clean_gas_update_logDAL_impl>();
            services.AddSingleton<ITeshu_gasDAL, Teshu_gasDAL_impl>();
            services.AddSingleton<ITeshu_gas_itemDAL, Teshu_gas_itemDAL_impl>();

            services.AddSingleton<ITeshu_gas_update_logDAL, Teshu_gas_update_logDAL_impl>();
            services.AddSingleton<ITeshu_gas_check_historyDAL, Teshu_gas_check_historyDAL_impl>();

            services.AddSingleton<IWater_point_itemDAL, Water_point_itemDAL_impl>();
            services.AddSingleton<IWater_pointDAL, Water_pointDAL_impl>();
            services.AddSingleton<IWater_check_historyDAL, Water_check_historyDAL_impl>();
            services.AddSingleton<IOrganic_sulfurDAL, Organic_sulfurDAL_impl>();
            services.AddSingleton<IOrganic_sulfur_check_historyDAL, Organic_sulfur_check_historyDAL_impl>();

            serviceProvider = services.BuildServiceProvider();
        }

        /// <summary>
        /// 获取接口实例
        /// </summary>
        /// <typeparam name="T">接口类型</typeparam>
        /// <returns></returns>
        /// 创建时间：2022-11-24 10:09:20。作者：王浩力
        public static T GetService<T>()
        {
            return serviceProvider.GetService<T>();
        }

    }
}
